var $ = layui.$;
$.prototype.serializeObject = function () {
    var obj = new Object();
    $.each(this.serializeArray(), function (index, param) {
        if (!(param.name in obj)) {
            obj[param.name] = param.value;
        }
    });
    return obj;
};
var layer = layui.layer;
var Func = {
    FormSubJson: function (form) {
        layer.load(1, {
            shade: [0.3, '#7a7a7a']
        });
        this.AjaxJson(form.attr("method"), form.attr("action"), form.serializeObject());
    },
    AjaxJson: function (type, url, data) {
        $.ajax({
            type: type,
            contentType: 'application/json;charset=utf-8',
            url: url,
            data: JSON.stringify(data),
            success: function (data) {
                layer.closeAll('loading');
                if (data.result) {
                    layer.closeAll();
                }
                layer.msg(data.msg);
            },
            error: function (data) {
                layer.closeAll('loading');
                layer.msg(data.msg);
            },
        });
    }
}